package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.EmployeeBasicInfoMapper;
import com.ruoyi.system.domain.EmployeeBasicInfo;
import com.ruoyi.system.service.IEmployeeBasicInfoService;

/**
 * 员工基本信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-05-25
 */
@Service
public class EmployeeBasicInfoServiceImpl implements IEmployeeBasicInfoService 
{
    @Autowired
    private EmployeeBasicInfoMapper employeeBasicInfoMapper;

    /**
     * 查询员工基本信息
     * 
     * @param employId 员工基本信息主键
     * @return 员工基本信息
     */
    @Override
    public EmployeeBasicInfo selectEmployeeBasicInfoByEmployId(Long employId)
    {
        return employeeBasicInfoMapper.selectEmployeeBasicInfoByEmployId(employId);
    }

    /**
     * 查询员工基本信息列表
     * 
     * @param employeeBasicInfo 员工基本信息
     * @return 员工基本信息
     */
    @DataScope(deptAlias = "d", userAlias = "u")
    @Override
    public List<EmployeeBasicInfo> selectEmployeeBasicInfoList(EmployeeBasicInfo employeeBasicInfo)
    {
        return employeeBasicInfoMapper.selectEmployeeBasicInfoList(employeeBasicInfo);
    }

    /**
     * 新增员工基本信息
     * 
     * @param employeeBasicInfo 员工基本信息
     * @return 结果
     */
    @Override
    public int insertEmployeeBasicInfo(EmployeeBasicInfo employeeBasicInfo)
    {
        //设置创建者id 部门id
        employeeBasicInfo.setUserId(SecurityUtils.getUserId());
        employeeBasicInfo.setDeptId(SecurityUtils.getDeptId());
        employeeBasicInfo.setCreateTime(DateUtils.getNowDate());
        return employeeBasicInfoMapper.insertEmployeeBasicInfo(employeeBasicInfo);
    }

    /**
     * 修改员工基本信息
     * 
     * @param employeeBasicInfo 员工基本信息
     * @return 结果
     */
    @Override
    public int updateEmployeeBasicInfo(EmployeeBasicInfo employeeBasicInfo)
    {
        employeeBasicInfo.setUpdateTime(DateUtils.getNowDate());
        return employeeBasicInfoMapper.updateEmployeeBasicInfo(employeeBasicInfo);
    }

    /**
     * 批量删除员工基本信息
     * 
     * @param employIds 需要删除的员工基本信息主键
     * @return 结果
     */
    @Override
    public int deleteEmployeeBasicInfoByEmployIds(Long[] employIds)
    {
        return employeeBasicInfoMapper.deleteEmployeeBasicInfoByEmployIds(employIds);
    }

    /**
     * 删除员工基本信息信息
     * 
     * @param employId 员工基本信息主键
     * @return 结果
     */
    @Override
    public int deleteEmployeeBasicInfoByEmployId(Long employId)
    {
        return employeeBasicInfoMapper.deleteEmployeeBasicInfoByEmployId(employId);
    }
}
